<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script type="text/javascript">
import { mapActions,mapGetters } from 'vuex'
import { getToken } from '@/utils/TokenOpers'
import axios from 'axios'
export default {
  created() {
    axios.get('/conf.json').then(e=>{
      this.$store.commit('SET_CONF',e.data)
      console.log("load!",{conf:e.data})
    }).catch(e=>{
      this.$message.error("配置文件加载失败")
    })
    this.GetUserInfo() //error->没有token
    .then(e=>{
      setTimeout(()=>{
        const {path} = this.$route
        const hasToken = getToken()
        if (hasToken && hasToken!=undefined && ['/','/user','/user/login'].includes(path))
          this.$router.push('/AutoSC/IndexPage')
      },500)
    })
    .catch(e=>{
      this.$router.push('/')
      this.$message.error("状态异常,请重新登录")
    })
  },
  methods:{
    ...mapActions(['GetUserInfo']),
  }
}
</script>
<style lang="less">
@import './style/common.less';
</style>